package com.zxl.designpattern.behavioral.responsibilitychain;

/**
 * 处理对象，帖子类
 * 封装了论坛帖子的相关信息
 */
public class Post {

    private String content;      // 帖子内容
    private String author;       // 帖子作者
    private boolean hasImage;    // 是否包含图片
    private boolean hasLink;     // 是否包含链接
    private boolean isApproved;  // 是否通过审核
    private String reason;       // 审核不通过的原因

    /**
     * 构造函数，初始化帖子信息
     * @param content 帖子内容
     * @param author 帖子作者
     * @param hasImage 是否包含图片
     * @param hasLink 是否包含链接
     */
    public Post(String content, String author, boolean hasImage, boolean hasLink) {
        this.content = content;
        this.author = author;
        this.hasImage = hasImage;
        this.hasLink = hasLink;
        this.isApproved = true;    //默认通过，这样只要一次不通过就审核失败。省去了多次通过需要设置true的代码
        this.reason = "";
    }

    // Getters and Setters
    public String getContent() {
        return content;
    }

    public String getAuthor() {
        return author;
    }

    public boolean hasImage() {
        return hasImage;
    }

    public boolean hasLink() {
        return hasLink;
    }

    public boolean isApproved() {
        return isApproved;
    }

    public void setApproved(boolean approved) {
        isApproved = approved;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    @Override
    public String toString() {
        return "作者: " + author + "，内容: " + content + 
               (isApproved ? "，审核状态: 通过" : "，审核状态: 未通过，原因: " + reason);
    }
}    